doc_dir: Path,
sources: Vec<SourceId>,
build: Vec<String>,
- unused_keys: Vec<String>,
+ warnings: Vec<String>,
}
impl Show for Manifest {
doc_dir: doc_dir.clone(),
sources: sources,
build: build,
- unused_keys: Vec::new(),
+ warnings: Vec::new(),
}
}
self.build.as_slice()
}
- pub fn add_unused_key(&mut self, s: String) {
- self.unused_keys.push(s)
+ pub fn add_warning(&mut self, s: String) {
+ self.warnings.push(s)
}
- pub fn get_unused_keys(&self) -> &[String] {
- self.unused_keys.as_slice()
+ pub fn get_warnings(&self) -> &[String] {
+ self.warnings.as_slice()
}
}
let package = try!(source.get_root_package());
debug!("loaded package; package={}", package);
- for key in package.get_manifest().get_unused_keys().iter() {
- try!(shell.warn(format!("unused manifest key: {}", key)));
+ for key in package.get_manifest().get_warnings().iter() {
+ try!(shell.warn(key))
}
let user_configs = try!(config::all_configs(os::getcwd()));
None => {}
}
if manifest.get_targets().len() == 0 {
- return Err(human(format!("either a [[lib]] or [[bin]] section must \
+ return Err(human(format!("either a [lib] or [[bin]] section must \
be present")))
}
return Ok((manifest, paths));
add_unused_keys(m, v, key.clone());
}
}
- _ => m.add_unused_key(key),
+ _ => m.add_warning(format!("unused manifest key: {}", key)),
}
}
}
// If we have a lib with a path, we're done
// If we have a lib with no path, use the inferred lib or_else package name
+ let mut used_deprecated_lib = false;
let lib = match self.lib {
Some(ref libs) => {
+ match *libs {
+ Many(..) => used_deprecated_lib = true,
+ _ => {}
+ }
libs.as_slice().iter().map(|t| {
if layout.lib.is_some() && t.path.is_none() {
TomlTarget {
try!(process_dependencies(&mut cx, true, self.dev_dependencies.as_ref()));
}
+ let build = match project.build {
+ Some(SingleBuildCommand(ref cmd)) => vec!(cmd.clone()),
+ Some(MultipleBuildCommands(ref cmd)) => cmd.clone(),
+ None => Vec::new()
+ };
+
let summary = Summary::new(&pkgid, deps.as_slice());
- Ok((Manifest::new(
- &summary,
- targets.as_slice(),
- &layout.root.join("target"),
- &layout.root.join("doc"),
- sources,
- match project.build {
- Some(SingleBuildCommand(ref cmd)) => vec!(cmd.clone()),
- Some(MultipleBuildCommands(ref cmd)) => cmd.clone(),
- None => Vec::new()
- }),
- nested_paths))
+ let mut manifest = Manifest::new(&summary,
+ targets.as_slice(),
+ &layout.root.join("target"),
+ &layout.root.join("doc"),
+ sources,
+ build);
+ if used_deprecated_lib {
+ manifest.add_warning(format!("the [[lib]] section has been \
+ deprecated in favor of [lib]"));
+ }
+ Ok((manifest, nested_paths))
}
}
version = "0.5.0"
authors = ["wycats@example.com"]
- [[lib]]
+ [lib]
name = "{}"
"#, name, name)
version = "0.5.0"
authors = ["wycats@example.com"]
- [[lib]]
+ [lib]
name = "bar"
"#)
baz = "0.5.0"
- [[lib]]
+ [lib]
name = "bar"
"#)
version = "0.5.0"
authors = ["wycats@example.com"]
- [[lib]]
+ [lib]
name = "baz"
"#)
version = "0.5.0"
- [[lib]]
+ [lib]
name = "bar"
"#)
version = "0.5.0"
authors = ["wycats@example.com"]
- [[lib]]
+ [lib]
name = "baz"
"#)
version = "0.5.0"
authors = ["wycats@example.com"]
- [[lib]]
+ [lib]
name = "foo"
crate_type = ["rlib", "dylib"]
version = "0.5.0"
authors = ["wycats@example.com"]
- [[lib]]
+ [lib]
name = "foo"
crate_type = ["rlib", "dylib"]
authors = ["wycats@example.com"]
bulid = "foo"
- [[lib]]
+ [lib]
name = "foo"
"#)
version = "0.5.0"
authors = ["wycats@example.com"]
- [[lib]]
+ [lib]
name = "foo"
build = "foo"
path = "."
- [[lib]]
+ [lib]
name = "test"
"#)
"#);
assert_that(p.cargo_process("cargo-build"),
execs().with_status(101)
- .with_stderr("either a [[lib]] or [[bin]] section \
+ .with_stderr("either a [lib] or [[bin]] section \
must be present\n"));
})
version = "0.0.0"
authors = []
- [[lib]]
+ [lib]
name = "foo"
crate_type = ["dylib", "rlib"]
"#)
version = "1.0.0"
authors = []
- [[lib]]
+ [lib]
name = "world"
path = "src/lib.rs"
authors = []
version = "0.0.1"
- [[lib]]
+ [lib]
name = "foo"
crate-type = ["staticlib"]
"#)
.file("src/bar.rs", "");
assert_that(p.cargo_process("cargo-build"), execs().with_status(0));
})
+
+test!(deprecated_lib {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ authors = []
+ version = "0.0.1"
+
+ [[lib]]
+ name = "foo"
+ "#)
+ .file("src/foo.rs", "");
+ assert_that(p.cargo_process("cargo-build"),
+ execs().with_status(0)
+ .with_stderr("\
+the [[lib]] section has been deprecated in favor of [lib]\n"));
+})
version = "0.5.0"
authors = ["carlhuda@example.com"]
- [[lib]]
+ [lib]
name = "dep1"
"#)
version = "0.5.0"
authors = ["carlhuda@example.com"]
- [[lib]]
+ [lib]
name = "dep1"
"#)
version = "0.5.0"
authors = ["carlhuda@example.com"]
- [[lib]]
+ [lib]
name = "dep1"
"#)
version = "0.5.0"
path = "vendor/dep2"
- [[lib]]
+ [lib]
name = "dep1"
"#)
version = "0.5.0"
authors = ["carlhuda@example.com"]
- [[lib]]
+ [lib]
name = "dep2"
"#)
version = "0.5.0"
authors = ["carlhuda@example.com"]
- [[lib]]
+ [lib]
name = "dep1"
"#)
version = "0.5.0"
authors = ["carlhuda@example.com"]
- [[lib]]
+ [lib]
name = "dep2"
"#)
version = "0.5.0"
authors = ["carlhuda@example.com"]
- [[lib]]
+ [lib]
name = "bar"
"#)
.file("src/bar.rs", r#"
version = "0.5.0"
authors = ["carlhuda@example.com"]
- [[lib]]
+ [lib]
name = "bar"
"#)
.file("src/bar.rs", r#"
version = "0.5.0"
path = "baz"
- [[lib]]
+ [lib]
name = "bar"
"#)
version = "0.5.0"
authors = ["wycats@example.com"]
- [[lib]]
+ [lib]
name = "baz"
"#)
git = "git://example.com/path/to/nowhere"
- [[lib]]
+ [lib]
name = "bar"
"#)
version = "0.5.0"
authors = ["wycats@example.com"]
- [[lib]] name = "bar"
+ [lib] name = "bar"
"#)
.file("bar/src/bar.rs", r#"
pub fn bar() {}
version = "0.5.0"
authors = ["wycats@example.com"]
- [[lib]]
+ [lib]
name = "bar"
[dependencies]
baz = "0.5.0"
version = "0.5.0"
authors = ["wycats@example.com"]
- [[lib]]
+ [lib]
name = "baz"
"#)
.file("baz/src/baz.rs", r#"
version = "0.5.0"
authors = ["wycats@example.com"]
- [[lib]]
+ [lib]
name = "bar"
[dependencies]
baz = "0.5.0"
version = "0.5.0"
authors = ["wycats@example.com"]
- [[lib]]
+ [lib]
name = "baz"
"#)
.file("baz/src/baz.rs", r#"
version = "0.5.0"
authors = ["wycats@example.com"]
- [[lib]]
+ [lib]
name = "bar"
"#)
path = "src/bar"
- [[lib]]
+ [lib]
name = "foo"
"#)
version = "0.0.1"
authors = []
- [[lib]]
+ [lib]
name = "foo_lib"
[dependencies.bar]
version = "0.0.1"
authors = []
- [[lib]]
+ [lib]
name = "bar"
plugin = true
version = "0.0.1"
authors = []
- [[lib]]
+ [lib]
name = "baz"
crate_type = ["dylib"]
"#)
version = "0.0.1"
authors = []
- [[lib]]
+ [lib]
name = "bar"
plugin = true
"#)
version = "0.0.1"
authors = []
- [[lib]]
+ [lib]
name = "bar"
plugin = true
version = "0.0.1"
authors = []
- [[lib]]
+ [lib]
name = "bar"
plugin = true
version = "0.0.1"
authors = []
- [[lib]]
+ [lib]
name = "baz"
crate_type = ["dylib"]
"#)
version = "0.0.1"
authors = []
- [[lib]]
+ [lib]
name = "bar"
crate-type = ["dylib"]
"#)
[dependencies.foo]
path = "../foo"
- [[lib]]
+ [lib]
name = "bar"
doctest = false
"#)
version = "0.0.1"
authors = []
- [[lib]]
+ [lib]
name = "foo"
[[bin]]
name = "foo"
version = "0.0.1"
authors = []
- [[lib]]
+ [lib]
name = "syntax"
test = false
doctest = false
version = "0.0.1"
authors = []
- [[lib]]
+ [lib]
name = "foo"
crate_type = ["dylib"]
version = "0.0.1"
authors = []
- [[lib]]
+ [lib]
name = "bar"
crate_type = ["dylib"]
"#)